package com.djzhou.gmms.dao.menu.impl;



import com.djzhou.gmms.dao.base.impl.BaseDAOImpl;
import com.djzhou.gmms.dao.menu.MenuDAO;
import com.djzhou.gmms.model.menu.TbMenu;
import com.djzhou.util.LevelCodeUtil;


public class MenuDAOImpl extends BaseDAOImpl<TbMenu> implements MenuDAO {
	@SuppressWarnings("unchecked")
	public String queryLevelCodeByParentId(Integer parentMenuId){
		String filterSql = parentMenuId==null ? " is null" : " = "+parentMenuId;
		String parentLevelCode="";
		//获取父级层级编码
		if(parentMenuId!=0)
			parentLevelCode = getHibernateTemplate().find("select backupData from TbMenu where menuId =" + parentMenuId).get(0).toString();
		//获取空位层级编码
		return new LevelCodeUtil().queryMaxNewLevelCode(getHibernateTemplate().find("select backupData from TbMenu where deleteFlag=0 and parentMenuId"+filterSql+" order by backupData"),parentLevelCode);
	}
	
	public String queryLevelCodeById(Integer menuId){
		return getHibernateTemplate().find("select backupData from TbMenu where menuId =" + menuId).get(0).toString();
	}
}
